home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / math / ast51src.zip / WDIALOG.C < prev    next >
C/C++ Source or Header  |  1995-12-31  |  54KB  |  1,737 lines

  1. /*
  2. ** Astrolog (Version 5.10) File: wdialog.c
  3. **
  4. ** IMPORTANT NOTICE: The graphics database and chart display routines
  5. ** used in this program are Copyright (C) 1991-1995 by Walter D. Pullen
  6. ** (Astara@msn.com). Permission is granted to freely use and
  7. ** distribute these routines provided one doesn't sell, restrict, or
  8. ** profit from them in any way. Modification is allowed provided these
  9. ** notices remain with any altered or edited versions of the program.
  10. **
  11. ** The main planetary calculation routines used in this program have
  12. ** been Copyrighted and the core of this program is basically a
  13. ** conversion to C of the routines created by James Neely as listed in
  14. ** Michael Erlewine's 'Manual of Computer Programming for Astrologers',
  15. ** available from Matrix Software. The copyright gives us permission to
  16. ** use the routines for personal use but not to sell them or profit from
  17. ** them in any way.
  18. **
  19. ** The PostScript code within the core graphics routines are programmed
  20. ** and Copyright (C) 1992-1993 by Brian D. Willoughby
  21. ** (brianw@sounds.wa.com). Conditions are identical to those above.
  22. **
  23. ** The extended accurate ephemeris databases and formulas are from the
  24. ** calculation routines in the program "Placalc" and are programmed and
  25. ** Copyright (C) 1989,1991,1993 by Astrodienst AG and Alois Treindl
  26. ** (alois@azur.ch). The use of that source code is subject to
  27. ** regulations made by Astrodienst Zurich, and the code is not in the
  28. ** public domain. This copyright notice must not be changed or removed
  29. ** by any user of this program.
  30. **
  31. ** Initial programming 8/28,30, 9/10,13,16,20,23, 10/3,6,7, 11/7,10,21/1991.
  32. ** X Window graphics initially programmed 10/23-29/1991.
  33. ** PostScript graphics initially programmed 11/29-30/1992.
  34. ** Last code change made 12/27/1995.
  35. */
  36.  
  37. #include "astrolog.h"
  38.  
  39.  
  40. #ifdef WIN
  41. /*
  42. ******************************************************************************
  43. ** Dialog Utility Functions.
  44. ******************************************************************************
  45. */
  46.  
  47. /* Set the contents of the given edit control in a dialog to a string. */
  48.  
  49. void SetEditSz(hdlg, id, sz)
  50. HWND hdlg;
  51. int id;
  52. char *sz;
  53. {
  54.   while (*sz == ' ')    /* Strip off any extra leading spaces. */
  55.     sz++;
  56.   SetEdit(id, sz);
  57. }
  58.  
  59.  
  60. /* Set the contents of the given edit control in a dialog to a floating */
  61. /* point value, with at most 'n' significant fractional digits.         */
  62.  
  63. void SetEditR(hdlg, id, r, n)
  64. HWND hdlg;
  65. int id;
  66. real r;
  67. int n;
  68. {
  69.   char sz[cchSzDef], szT[8], *pch;
  70.  
  71.   sprintf(szT, "%%.%df", n);
  72.   sprintf(sz, szT, r);
  73.   for (pch = sz; *pch; pch++)
  74.     ;
  75.   while (*(--pch) == '0')          /* Drop off any trailing zero digits. */
  76.     ;
  77.   pch[1 + (*pch == '.')] = chNull; /* Ensure at least one fractional digit. */
  78.   SetEdit(id, sz);
  79. }
  80.  
  81.  
  82. /* Set the contents of four combo controls and their dropdowns in a dialog */
  83. /* indicating month, day, year, and time fields to the given values.       */
  84.  
  85. void SetEditMDYT(hdlg, idMon, idDay, idYea, idTim, mon, day, yea, tim)
  86. HWND hdlg;
  87. int idMon, idDay, idYea, idTim;
  88. int mon, day, yea;
  89. real tim;
  90. {
  91.   char sz[cchSzDef];
  92.   int i;
  93.  
  94.   ClearCombo(idMon);
  95.   ClearCombo(idDay);
  96.   ClearCombo(idYea);
  97.   ClearCombo(idTim);
  98.   if (!FValidMon(mon))
  99.     mon = 1;
  100.   sprintf(sz, "%c%c%c", chMon3(mon));
  101.   SetEdit(idMon, sz);
  102.   for (i = 1; i <= cSign; i++)
  103.     SetCombo(idMon, szMonth[i]);
  104.   if (!FValidDay(day, mon, yea))
  105.     day = 1;
  106.   SetEditN(idDay, day);
  107.   SetCombo(idDay, "1"); SetCombo(idDay, "15");
  108.   SetEditN(idYea, yea);
  109.   for (i = 1990; i < 2000; i++) {
  110.     sprintf(sz, "%d", i); SetCombo(idYea, sz);
  111.   }
  112.   sprintf(sz, "%s", SzTim(tim));
  113.   SetEditSz(hdlg, idTim, sz);
  114.   SetCombo(idTim, "Midnight");
  115.   SetCombo(idTim, (char *)(us.fEuroTime ? "6:00" : "6:00am"));
  116.   SetCombo(idTim, "Noon");
  117.   SetCombo(idTim, (char *)(us.fEuroTime ? "18:00" : "6:00pm"));
  118. }
  119.  
  120.  
  121. /* Set the contents of four combo controls in a dialog indicating daylight, */
  122. /* time zone, longitude, and latitude fields to the given values.           */
  123.  
  124. void SetEditSZOA(hdlg, idDst, idZon, idLon, idLat, dst, zon, lon, lat)
  125. HWND hdlg;
  126. int idDst, idZon, idLon, idLat;
  127. real dst, zon, lon, lat;
  128. {
  129.   char sz[cchSzDef];
  130.   int i;
  131.   bool fT;
  132.  
  133.   if (dst == 0.0 || dst == 1.0)
  134.     sprintf(sz, "%s", dst == 0.0 ? "No" : "Yes");
  135.   else
  136.     sprintf(sz, "%.2f", dst);
  137.   SetEdit(idDst, sz);
  138.   SetCombo(idDst, "No"); SetCombo(idDst, "Yes");
  139.   sprintf(sz, "%s", SzZone(-zon));
  140.   SetEdit(idZon, (char *)(sz[0] == '+' ? &sz[1] : sz));
  141.   /* For the time zone dropdown, fill it out with all abbreviations of */
  142.   /* three letters that don't reference daylight or war time.          */
  143.   for (i = 0; i < cZone; i++) {
  144.     if (szZon[i][1] && szZon[i][1] != 'D' && szZon[i][1] != 'W' &&
  145.       szZon[i][2] && szZon[i][2] != 'D')
  146.       SetCombo(idZon, szZon[i]);
  147.   }
  148.   fT = us.fAnsi; us.fAnsi = fFalse;
  149.   sprintf(sz, "%s", SzLocation(lon, lat));
  150.   us.fAnsi = fT;
  151.   sz[7] = chNull;
  152.   SetEditSz(hdlg, idLon, &sz[0]);
  153.   SetCombo(idLon, "122W20"); SetCombo(idLon, "0E00");
  154.   SetEditSz(hdlg, idLat, &sz[8]);
  155.   SetCombo(idLat, "47N36"); SetCombo(idLat, "0S00");
  156. }
  157.  
  158.  
  159. /* Set the contents of a combo control in a dialog indicating a color   */
  160. /* field to the given value, and fill its dropdown with the color list. */
  161.  
  162. void SetEditColor(hdlg, id, ki)
  163. HWND hdlg;
  164. int id;
  165. KI ki;
  166. {
  167.   int i;
  168.  
  169.   SetEdit(id, szColor[ki]);
  170.   for (i = 0; i < cColor; i++)
  171.     SetCombo(id, szColor[i]);
  172. }
  173.  
  174.  
  175. /* Return the contents of a dialog edit control as a floating point value. */
  176.  
  177. real GetEditR(hdlg, id)
  178. HWND hdlg;
  179. int id;
  180. {
  181.   char sz[cchSzDef];
  182.  
  183.   GetEdit(id, sz);
  184.   return atof(sz);
  185. }
  186.  
  187.  
  188. /* Bring up an error box indicating an illegal value for a dialog field. */
  189.  
  190. void ErrorEnsure(n, sz)
  191. int n;
  192. char *sz;
  193. {
  194.   char szT[cchSzDef];
  195.  
  196.   sprintf(szT, "The value %d is not a valid %s setting.", n, sz);
  197.   PrintWarning(szT);
  198. }
  199.  
  200.  
  201. /* Take many of the user visible settings, and write them out to a new     */
  202. /* command switch file, which may be read in to restore those settings.    */
  203. /* Most often this would be used to create a new astrolog.dat default      */
  204. /* settings file. This is called from the File Save Settings menu command. */
  205.  
  206. bool FOutputSettings()
  207. {
  208.   char sz[cchSzDef];
  209.   FILE *file;
  210.   int i;
  211.   bool fT;
  212.  
  213.   if (us.fNoWrite)
  214.     return fFalse;
  215.   file = fopen(is.szFileOut, "w");  /* Create and open the file for output. */
  216.   if (file == NULL) {
  217.     sprintf(sz, "Settings file %s can not be created.", is.szFileOut);
  218.     PrintError(sz);
  219.     return fFalse;
  220.   }
  221.  
  222.   sprintf(sz, "@0308  ; %s (%s) default settings file %s\n\n",
  223.     szAppName, szVersionCore, DEFAULT_INFOFILE); PrintFSz();
  224.  
  225.   sprintf(sz, "-z0 %d             ", (int)us.dstDef); PrintFSz();
  226.   PrintF("; Default Daylight time setting   [0 standard, 1 daylight]\n");
  227.   sprintf(sz, "-z %s          ", SzZone(-us.zonDef)); PrintFSz();
  228.   PrintF("; Default time zone               [hours before GMT      ]\n");
  229.   fT = us.fAnsi; us.fAnsi = -2;
  230.   sprintf(sz, "-zl %s  ", SzLocation(us.lonDef, us.latDef)); PrintFSz();
  231.   us.fAnsi = fT;
  232.   PrintF("; Default longitude and latitude\n-n                ");
  233.   PrintF("; Uncomment this line to start with the chart for \"now\".\n\n");
  234.  
  235.   sprintf(sz, "%cs      ", ChDashF(us.fSidereal)); PrintFSz();
  236.   PrintF(
  237.     "; Zodiac selection          [\"_s\" is tropical, \"=s\" is siderial]\n");
  238.   sprintf(sz, ":s %.0f    ", us.rZodiacOffset); PrintFSz();
  239.   PrintF(
  240.     "; Zodiac offset value       [Change \"0\" to desired offset      ]\n");
  241.   sprintf(sz, "-A %d    ", us.nAsp); PrintFSz();
  242.   PrintF(
  243.     "; Number of aspects         [Change \"5\" to desired number      ]\n");
  244.   sprintf(sz, "-c %d    ", us.nHouseSystem); PrintFSz();
  245.   PrintF(
  246.     "; House system              [Change \"0\" to desired system      ]\n");
  247.   sprintf(sz, "%ck      ", ChDashF(us.fAnsi)); PrintFSz();
  248.   PrintF(
  249.     "; Ansi color text           [\"=k\" is color, \"_k\" is normal     ]\n");
  250.   sprintf(sz, ":d %d   ", us.nDivision); PrintFSz();
  251.   PrintF(
  252.     "; Searching divisions       [Change \"12\" to desired divisions  ]\n");
  253.   sprintf(sz, "%cb0     ", ChDashF(us.fSeconds)); PrintFSz();
  254.   PrintF(
  255.     "; Print zodiac seconds      [\"_b0\" to minute, \"=b0\" to second  ]\n");
  256.   sprintf(sz, "%cb      ", ChDashF(us.fPlacalc)); PrintFSz();
  257.   PrintF(
  258.     "; Use ephemeris files       [\"=b\" uses them, \"_b\" doesn't      ]\n");
  259.   sprintf(sz, "%cC      ", ChDashF(us.fCusp)); PrintFSz();
  260.   PrintF(
  261.     "; Show house cusp objects   [\"_C\" hides them, \"=C\" shows them  ]\n");
  262.   sprintf(sz, ":w %d    ", us.nWheelRows); PrintFSz();
  263.   PrintF(
  264.     "; Wheel chart text rows     [Change \"4\" to desired wheel rows  ]\n");
  265.   sprintf(sz, ":I %d   ", us.nScreenWidth); PrintFSz();
  266.   PrintF(
  267.     "; Text screen columns       [Change \"80\" to desired columns    ]\n");
  268.   sprintf(sz, "-YQ %d  ", us.nScrollRow); PrintFSz();
  269.   PrintF(
  270.     "; Text screen scroll limit  [Change \"24\" or set to \"0\" for none]\n");
  271.   sprintf(sz, "%cYd     ", ChDashF(us.fEuroDate)); PrintFSz();
  272.   PrintF(
  273.     "; European date format      [\"_Yd\" is MDY, \"=Yd\" is DMY        ]\n");
  274.   sprintf(sz, "%cYt     ", ChDashF(us.fEuroTime)); PrintFSz();
  275.   PrintF(
  276.     "; European time format      [\"_Yt\" is AM/PM, \"=Yt\" is 24 hour  ]\n");
  277.   sprintf(sz, "%cYC     ", ChDashF(us.fSmartCusp)); PrintFSz();
  278.   PrintF(
  279.     "; Smart cusp displays       [\"=YC\" is smart, \"_YC\" is normal   ]\n");
  280.   sprintf(sz, "%cY8     ", ChDashF(us.fClip80)); PrintFSz();
  281.   PrintF(
  282.     "; Clip text to end of line  [\"=Y8\" clips, \"_Y8\" doesn't clip   ]\n");
  283.   sprintf(sz, "-Yz %ld   ", us.lTimeAddition); PrintFSz();
  284.   PrintF(
  285.     "; Time minute addition      [Change only if -n charts are off  ]\n\n\n");
  286.  
  287.   PrintF("; DEFAULT RESTRICTIONS:\n\n-YR 1 10     ");
  288.   for (i = 1; i <= 10; i++) PrintF(SzNumF(ignore[i]));
  289.   PrintF("     ; Planets\n-YR 11 20    ");
  290.   for (i = 11; i <= 20; i++) PrintF(SzNumF(ignore[i]));
  291.   PrintF("     ; Minor planets\n-YR 21 32    ");
  292.   for (i = 21; i <= 32; i++) PrintF(SzNumF(ignore[i]));
  293.   PrintF(" ; House cusps\n-YR 33 40    ");
  294.   for (i = 33; i <= 40; i++) PrintF(SzNumF(ignore[i]));
  295.   PrintF("         ; Uranians\n\n");
  296.  
  297.   PrintF("; DEFAULT TRANSIT RESTRICTIONS:\n\n-YRT 1 10    ");
  298.   for (i = 1; i <= 10; i++) PrintF(SzNumF(ignore2[i]));
  299.   PrintF("     ; Planets\n-YRT 11 20   ");
  300.   for (i = 11; i <= 20; i++) PrintF(SzNumF(ignore2[i]));
  301.   PrintF("     ; Minor planets\n-YRT 21 32   ");
  302.   for (i = 21; i <= 32; i++) PrintF(SzNumF(ignore2[i]));
  303.   PrintF(" ; House cusps\n-YRT 33 40   ");
  304.   for (i = 33; i <= 40; i++) PrintF(SzNumF(ignore2[i]));
  305.   PrintF("         ; Uranians\n\n");
  306.  
  307.   sprintf(sz, "-YR0 %s%s ; Restrict sign, direction changes\n\n\n",
  308.     SzNumF(ignore[0]), SzNumF(ignore2[0])); PrintFSz();
  309.  
  310.   PrintF("; DEFAULT ASPECT ORBS:\n\n-YAo 1 5    ");
  311.   for (i = 1; i <= 5; i++) { sprintf(sz, " %.0f", rAspOrb[i]); PrintFSz(); }
  312.   PrintF("      ; Major aspects\n-YAo 6 11   ");
  313.   for (i = 6; i <= 11; i++) { sprintf(sz, " %.0f", rAspOrb[i]); PrintFSz(); }
  314.   PrintF("    ; Minor aspects\n-YAo 12 18  ");
  315.   for (i = 12; i <= 18; i++) { sprintf(sz, " %.0f", rAspOrb[i]); PrintFSz(); }
  316.   PrintF("  ; Obscure aspects\n\n");
  317.  
  318.   PrintF("; DEFAULT MAX PLANET ASPECT ORBS:\n\n-YAm 1 10   ");
  319.   for (i = 1; i <= 10; i++) { sprintf(sz, "%4.0f", rObjOrb[i]); PrintFSz(); }
  320.   PrintF("\n-YAm 11 20  ");
  321.   for (i = 11; i <= 20; i++) { sprintf(sz, "%4.0f", rObjOrb[i]); PrintFSz(); }
  322.   PrintF("\n-YAm 21 32  ");
  323.   for (i = 21; i <= 32; i++) { sprintf(sz, "%4.0f", rObjOrb[i]); PrintFSz(); }
  324.   PrintF("\n-YAm 33 40  ");
  325.   for (i = 33; i <= 40; i++) { sprintf(sz, "%4.0f", rObjOrb[i]); PrintFSz(); }
  326.  
  327.   PrintF("\n\n; DEFAULT PLANET ASPECT ORB ADDITIONS:\n\n-YAd 1 10   ");
  328.   for (i = 1; i <= 10; i++) { sprintf(sz, " %.0f", rObjAdd[i]); PrintFSz(); }
  329.   PrintF("\n-YAd 11 20  ");
  330.   for (i = 11; i <= 20; i++) { sprintf(sz, " %.0f", rObjAdd[i]); PrintFSz(); }
  331.   PrintF("\n-YAd 21 32  ");
  332.   for (i = 21; i <= 32; i++) { sprintf(sz, " %.0f", rObjAdd[i]); PrintFSz(); }
  333.  
  334.   PrintF("\n\n\n; DEFAULT INFLUENCES:\n\n-Yj 1 10   ");
  335.   for (i = 1; i <= 10; i++) { sprintf(sz, " %.0f", rObjInf[i]); PrintFSz(); }
  336.   PrintF("        ; Planets\n-Yj 11 20  ");
  337.   for (i = 11; i <= 20; i++) { sprintf(sz, " %.0f", rObjInf[i]); PrintFSz(); }
  338.   PrintF("                  ; Minor planets\n-Yj 21 32  ");
  339.   for (i = 21; i <= 32; i++) { sprintf(sz, " %.0f", rObjInf[i]); PrintFSz(); }
  340.   PrintF("  ; Cusp objects\n-Yj 33 40  ");
  341.   for (i = 33; i <= 40; i++) { sprintf(sz, " %.0f", rObjInf[i]); PrintFSz(); }
  342.   PrintF("                      ; Uranians\n\n-YjC 1 12  ");
  343.  
  344.   for (i = 1; i <= 12; i++) { sprintf(sz, " %.0f", rHouseInf[i]); PrintFSz(); }
  345.   PrintF("  ; Houses\n\n-YjA 1 5   ");
  346.  
  347.   for (i = 1; i <= 5; i++) { sprintf(sz, "%4.1f", rAspInf[i]); PrintFSz(); }
  348.   PrintF("          ; Major aspects\n-YjA 6 11  ");
  349.   for (i = 6; i <= 11; i++) { sprintf(sz, "%4.1f", rAspInf[i]); PrintFSz(); }
  350.   PrintF("      ; Minor aspects\n-YjA 12 18 ");
  351.   for (i = 12; i <= 18; i++) { sprintf(sz, "%4.1f", rAspInf[i]); PrintFSz(); }
  352.   PrintF("  ; Obscure aspects\n\n");
  353.  
  354.   PrintF("; DEFAULT TRANSIT INFLUENCES:\n\n-YjT 1 10   ");
  355.   for (i = 1; i <= 10; i++)
  356.     { sprintf(sz, " %.0f", rTransitInf[i]); PrintFSz(); }
  357.   PrintF("  ; Planets\n-YjT 11 20  ");
  358.   for (i = 11; i <= 20; i++)
  359.     { sprintf(sz, " %.0f", rTransitInf[i]); PrintFSz(); }
  360.   PrintF("   ; Minor planets\n-YjT 33 40  ");
  361.   for (i = 33; i <= 40; i++)
  362.     { sprintf(sz, " %.0f", rTransitInf[i]); PrintFSz(); }
  363.  
  364.   sprintf(sz, "     ; Uranians\n\n-Yj0 %.0f %.0f %.0f %.0f ",
  365.     rObjInf[oNorm + 1], rObjInf[oNorm + 2], rHouseInf[cSign + 1],
  366.     rHouseInf[cSign + 2]); PrintFSz();
  367.   PrintF("; In ruling sign, exalted sign, ruling house, exalted house.\n\n\n");
  368.  
  369.   PrintF("; GRAPHICS DEFAULTS:\n\n");
  370.   sprintf(sz, "%cX              ", ChDashF(us.fGraphics)); PrintFSz();
  371.   PrintF("; Graphics chart flag [\"_X\" is text, \"=X\" is graphics]\n");
  372.   i = gs.xWin; if (fSidebar) i -= SIDESIZE;
  373.   sprintf(sz, ":Xw %d %d     ", i, gs.yWin); PrintFSz();
  374.   PrintF("; Default X and Y resolution\n");
  375.   sprintf(sz, ":Xb%c            ", ChUncap(gs.chBmpMode)); PrintFSz();
  376.   PrintF("; Bitmap file type\n");
  377.   sprintf(sz, ":YXG %d       ", gs.nGlyphs); PrintFSz();
  378.   PrintF("; Glyph selections\n");
  379.   sprintf(sz, ":YXg %d         ", gs.nGridCell); PrintFSz();
  380.   PrintF("; Aspect grid cells\n");
  381.   sprintf(sz, ":YXf %d          ", gs.fFont); PrintFSz();
  382.   PrintF("; Use actual fonts\n");
  383.   sprintf(sz, ":YXp %d          ", gs.nOrient); PrintFSz();
  384.   PrintF("; PostScript paper orientation\n");
  385.   sprintf(sz, ":YXp0 %.1f %.1f  ", gs.xInch, gs.yInch); PrintFSz();
  386.   PrintF("; PostScript paper X and Y inch sizes\n");
  387.   PrintF(":YX -1 16       ; PC hi-res and lo-res graphics modes\n\n");
  388.  
  389.   sprintf(sz, "; %s\n", DEFAULT_INFOFILE); PrintFSz();
  390.   fclose(file);
  391.   return fTrue;
  392. }
  393.  
  394.  
  395. /*
  396. ******************************************************************************
  397. ** Windows Dialogs.
  398. ******************************************************************************
  399. */
  400.  
  401. /* Bring up the Windows standard file open dialog, and process the        */
  402. /* command file specified if any. This is called from the File Open Chart */
  403. /* and File Open Chart #2 menu commands.                                  */
  404.  
  405. bool API DlgOpenChart()
  406. {
  407.   CI ciT;
  408.  
  409.   /* Setup dialog title and settings and get the name of a file from it. */
  410.   if (us.fNoRead) {
  411.     PrintWarning("File input is not allowed now.");
  412.     return fFalse;
  413.   }
  414.   if (wi.wCmd == cmdOpenChart)
  415.     ofn.lpstrTitle = "Open Chart";
  416.   else
  417.     ofn.lpstrTitle = "Open Chart #2";
  418.   ofn.lpstrFilter = "All Files (*.*)\0*.*\0Data Files (*.DAT)\0*.DAT\0";
  419.   szFileName[0] = chNull;
  420.   if (!GetOpenFileName((LPOPENFILENAME)&ofn))
  421.     return fFalse;
  422.  
  423.   /* Process the given file based on what open command is being run. */
  424.   if (wi.wCmd == cmdOpenChart2)
  425.     ciT = ciCore;
  426.   FInputData(ofn.lpstrFileTitle);
  427.   if (wi.wCmd == cmdOpenChart2) {
  428.     ciTwin = ciCore;
  429.     ciCore = ciT;
  430.   }
  431.  
  432.   wi.fCast = fTrue;
  433.   return fTrue;
  434. }
  435.  
  436.  
  437. /* Bring up the Windows standard file save dialog, get the name of a file   */
  438. /* from the user, and save to it either right away or set variables to      */
  439. /* ensure it will be done later. This is called from all six File Save menu */
  440. /* commands: Save Info, Positions, Text, Bitmap, Picture, and PostScript.   */
  441.  
  442. bool API DlgSaveChart()
  443. {
  444.   char *pch;
  445.  
  446.   /* Setup dialog title and settings and get the name of a file from it. */
  447.   if (us.fNoWrite) {
  448.     PrintWarning("File output is not allowed now.");
  449.     return fFalse;
  450.   }
  451.   ofn.lpstrFilter = "All Files (*.*)\0*.*\0Data Files (*.DAT)\0*.DAT\0";
  452.   szFileName[0] = chNull;
  453.   switch (wi.wCmd) {
  454.   case cmdSaveChart:
  455.     ofn.lpstrTitle = "Save Chart Info";
  456.     break;
  457.   case cmdSavePositions:
  458.     ofn.lpstrTitle = "Save Chart Positions";
  459.     break;
  460.   case cmdSaveText:
  461.     ofn.lpstrTitle = "Save Chart Text";
  462.     ofn.lpstrFilter = "All Files (*.*)\0*.*\0Text Files (*.TXT)\0*.TXT\0";
  463.     break;
  464.   case cmdSaveBitmap:
  465.     ofn.lpstrTitle = "Save Chart Bitmap";
  466.     ofn.lpstrFilter =
  467.       "Windows Bitmap (*.BMP)\0*.BMP\0All Files (*.*)\0*.*\0";
  468.     break;
  469.   case cmdSavePicture:
  470.     ofn.lpstrTitle = "Save Chart Picture";
  471.     ofn.lpstrFilter =
  472.       "Windows Metafile (*.WMF)\0*.WMF\0All Files (*.*)\0*.*\0";
  473.     break;
  474.   case cmdSavePS:
  475.     ofn.lpstrTitle = "Save Chart PostScript";
  476.     ofn.lpstrFilter =
  477.       "PostScript Text (*.EPS)\0*.EPS\0All Files (*.*)\0*.*\0";
  478.     break;
  479.   case cmdSaveSettings:
  480.     ofn.lpstrTitle = "Save Settings";
  481.     ofn.lpstrFilter = "Data Files (*.DAT)\0*.DAT\0All Files (*.*)\0*.*\0";
  482.     sprintf(szFileName, "%s", DEFAULT_INFOFILE);
  483.     break;
  484.   }
  485.   if (wi.wCmd != cmdSaveWallTile && wi.wCmd != cmdSaveWallCenter) {
  486.     if (!GetSaveFileName((LPOPENFILENAME)&ofn))
  487.       return fFalse;
  488.   } else {
  489.     ofn.lpstrFile = PAllocate(cchSzDef, fTrue, NULL);
  490.     GetWindowsDirectory(ofn.lpstrFile, cchSzDef);
  491.     pch = ofn.lpstrFile + CchSz(ofn.lpstrFile);
  492.     sprintf(pch, "%c%s%s", '\\', szAppName, ".bmp");
  493.   }
  494.  
  495.   /* Saving chart info, position, or setting command files can be done  */
  496.   /* here. Saving actual chart output isn't done until the next redraw. */
  497.   is.szFileOut = gi.szFileOut = ofn.lpstrFile;
  498.   switch (wi.wCmd) {
  499.   case cmdSaveChart:
  500.     us.fWritePos = fFalse;
  501.     return FOutputData();
  502.   case cmdSavePositions:
  503.     us.fWritePos = fTrue;
  504.     return FOutputData();
  505.   case cmdSaveText:
  506.     is.szFileScreen = ofn.lpstrFile;
  507.     us.fGraphics = fFalse;
  508.     wi.fRedraw = fTrue;
  509.     break;
  510.   case cmdSaveBitmap:
  511.   case cmdSaveWallTile:
  512.   case cmdSaveWallCenter:
  513.     gs.fBitmap = fTrue;
  514.     gs.fMeta = gs.fPS = fFalse;
  515.     us.fGraphics = wi.fRedraw = fTrue;
  516.     break;
  517.   case cmdSavePicture:
  518.     gs.fMeta = fTrue;
  519.     gs.fBitmap = gs.fPS = fFalse;
  520.     us.fGraphics = wi.fRedraw = fTrue;
  521.     break;
  522.   case cmdSavePS:
  523.     gs.fPS = fTrue;
  524.     gs.fBitmap = gs.fMeta = fFalse;
  525.     us.fGraphics = wi.fRedraw = fTrue;
  526.     break;
  527.   case cmdSaveSettings:
  528.     return FOutputSettings();
  529.   }
  530.   return fTrue;
  531. }
  532.  
  533.  
  534. /* Bring up the Windows standard print dialog, receive any printing       */
  535. /* settings from the user, and proceed to print the current graphics or   */
  536. /* text chart as displayed in the window. Called from File Print command. */
  537.  
  538. bool API DlgPrint()
  539. {
  540.   FARPROC lpAbortDlg, lpAbortProc;
  541.   HDC hdc;
  542.   LPDEVMODE lpDevMode = NULL;
  543.   LPDEVNAMES lpDevNames;
  544.   LPSTR lpszDriverName;
  545.   LPSTR lpszDeviceName;
  546.   LPSTR lpszPortName;
  547.   DOCINFO doci;
  548.   int xPrint, yPrint;
  549.   int xClient, yClient;
  550.   short xScroll, yScroll;
  551.  
  552.   /* Bring up the Windows print dialog. */
  553.   if (!PrintDlg((LPPRINTDLG)&prd))
  554.     return fTrue;
  555.  
  556.   /* Get the printer DC. */
  557.   if (prd.hDC)
  558.     hdc = prd.hDC;
  559.   else {
  560.     /* If the dialog didn't just return the DC, try to make one manually. */
  561.     if (!prd.hDevNames)
  562.       return fFalse;
  563.     lpDevNames = (LPDEVNAMES)GlobalLock(prd.hDevNames);
  564.     lpszDriverName = (LPSTR)lpDevNames + lpDevNames->wDriverOffset;
  565.     lpszDeviceName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
  566.     lpszPortName = (LPSTR)lpDevNames + lpDevNames->wOutputOffset;
  567.     GlobalUnlock(prd.hDevNames);
  568.     if (prd.hDevMode)
  569.       lpDevMode = (LPDEVMODE)GlobalLock(prd.hDevMode);
  570.     hdc = CreateDC(lpszDriverName, lpszDeviceName, lpszPortName,
  571.       (LPSTR)lpDevMode);
  572.     if (prd.hDevMode && lpDevMode)
  573.       GlobalUnlock(prd.hDevMode);
  574.   }
  575.   if (prd.hDevNames) {
  576.     GlobalFree(prd.hDevNames);
  577.     prd.hDevNames = (HGLOBAL)NULL;
  578.   }
  579.   if (prd.hDevMode) {
  580.     GlobalFree(prd.hDevMode);
  581.     prd.hDevMode = (HGLOBAL)NULL;
  582.   }
  583.  
  584.   /* Setup the abort dialog and start the print job. */
  585.   lpAbortDlg = MakeProcInstance(DlgAbort, wi.hinst);
  586.   lpAbortProc = MakeProcInstance(DlgAbortProc, wi.hinst);
  587.   SetAbortProc(hdc, lpAbortProc);
  588.   doci.cbSize = sizeof(DOCINFO);
  589.   doci.lpszDocName = szAppName;
  590.   doci.lpszOutput = NULL;
  591.   if (StartDoc(hdc, &doci) < 0) {
  592.     FreeProcInstance(lpAbortDlg);
  593.     FreeProcInstance(lpAbortProc);
  594.     DeleteDC(hdc);
  595.     return fFalse;
  596.   }
  597.   wi.fAbort = FALSE;
  598.   wi.hwndAbort = CreateDialog(wi.hinst, MAKEINTRESOURCE(dlgAbort), wi.hwnd,
  599.     lpAbortDlg);
  600.   if (!wi.hwndAbort)
  601.     return fFalse;
  602.   ShowWindow(wi.hwndAbort, SW_NORMAL);
  603.   EnableWindow(wi.hwnd, fFalse);
  604.   StartPage(hdc);
  605.  
  606.   /* Scale the chart to the page. */
  607.   SetMapMode(hdc, MM_ANISOTROPIC);       /* So SetViewPortExt can be called */
  608.   xPrint = GetDeviceCaps(hdc, HORZRES);
  609.   yPrint = GetDeviceCaps(hdc, VERTRES);
  610.   SetViewportOrg(hdc, 0, 0);
  611.   SetViewportExt(hdc, xPrint, yPrint);
  612.   xClient = wi.xClient; yClient = wi.yClient;
  613.   wi.xClient = gs.xWin;
  614.   wi.yClient = NMultDiv(wi.xClient, yPrint, xPrint);
  615.   if (gs.yWin > wi.yClient) {
  616.     wi.yClient = gs.yWin;
  617.     wi.xClient = NMultDiv(wi.yClient, xPrint, yPrint);
  618.   }
  619.   xScroll = wi.xScroll; yScroll = wi.yScroll;
  620.   wi.xScroll = wi.yScroll = 0;
  621.   wi.hdcPrint = hdc;
  622.  
  623.   FRedraw();    /* Actually go "draw" the chart to the printer. */
  624.  
  625.   /* Restore globals that were temporarily changed to print above. */
  626.   wi.hdcPrint = hdcNil;
  627.   wi.xScroll = xScroll; wi.yScroll = yScroll;
  628.   wi.xClient = xClient; wi.yClient = yClient;
  629.  
  630.   /* Finalize and cleanup everything. */
  631.   if (!wi.fAbort) {
  632.     EndPage(hdc);
  633.     EndDoc(hdc);
  634.   }
  635.   EnableWindow(wi.hwnd, fTrue);
  636.   DestroyWindow(wi.hwndAbort);
  637.   FreeProcInstance(DlgAbort);
  638.   FreeProcInstance(DlgAbortProc);
  639.   DeleteDC(hdc);
  640.  
  641.   return fTrue;
  642. }
  643.  
  644.  
  645. /* Message loop function for the printing abort dialog. Loops until       */
  646. /* printing is completed or the user hits cancel, returning which result. */
  647.  
  648. bool API DlgAbortProc(hdc, nCode)
  649. HDC hdc;
  650. int nCode;
  651. {
  652.   MSG msg;
  653.  
  654.   if (wi.hwndAbort == (HWND)NULL)
  655.     return fTrue;
  656.   while (!wi.fAbort && PeekMessage(&msg, (HWND)NULL, 0, 0, PM_REMOVE))
  657.     if (!IsDialogMessage(wi.hwndAbort, &msg)) {
  658.       TranslateMessage(&msg);
  659.       DispatchMessage(&msg);
  660.     }
  661.   return !wi.fAbort;
  662. }
  663.  
  664.  
  665. /* Processing function for the printing abort modeless dialog, as brought */
  666. /* up temporarily when printing via the File Print menu command.          */
  667.  
  668. bool API DlgAbort(hdlg, message, wParam, lParam)
  669. HWND hdlg;
  670. _int message;
  671. WORD wParam;
  672. LONG lParam;
  673. {
  674.   switch (message) {
  675.   case WM_INITDIALOG:
  676.     SetFocus(GetDlgItem(hdlg, IDCANCEL));
  677.     return fFalse;
  678.  
  679.   case WM_COMMAND:
  680.     if (wParam == IDOK || wParam == IDCANCEL) {
  681.       wi.fAbort = fTrue;
  682.       EndDialog(hdlg, fTrue);
  683.       return fTrue;
  684.     }
  685.     break;
  686.   }
  687.   return fFalse;
  688. }
  689.  
  690.  
  691. /* Processing function for the command switch entry dialog, as brought up */
  692. /* with the Edit Enter Command Line menu command.                         */
  693.  
  694. bool API DlgCommand(hdlg, message, wParam, lParam)
  695. HWND hdlg;
  696. _int message;
  697. WORD wParam;
  698. LONG lParam;
  699. {
  700.   char sz[cchSzDef];
  701.  
  702.   switch (message) {
  703.   case WM_INITDIALOG:
  704.     SetFocus(GetDlgItem(hdlg, deCo));
  705.     return fFalse;
  706.  
  707.   case WM_COMMAND:
  708.     if (wParam == IDOK) {
  709.       GetDlgItemText(hdlg, deCo, sz, cchSzDef);
  710.       FProcessCommandLine(sz);
  711.       wi.fCast = wi.fMenuAll = fTrue;
  712.     }
  713.     if (wParam == IDOK || wParam == IDCANCEL) {
  714.       EndDialog(hdlg, fTrue);
  715.       return fTrue;
  716.     }
  717.     break;
  718.   }
  719.   return fFalse;
  720. }
  721.  
  722.  
  723. /* Processing function for the color customization dialog, as brought up */
  724. /* with the View Set Colors menu command.                                */
  725.  
  726. bool API DlgColor(hdlg, message, wParam, lParam)
  727. HWND hdlg;
  728. _int message;
  729. WORD wParam;
  730. LONG lParam;
  731. {
  732.   char sz[cchSzDef];
  733.   int i, j, k, l;
  734.  
  735.   switch (message) {
  736.   case WM_INITDIALOG:
  737.     for (i = 0; i < 4; i++)
  738.       SetEditColor(hdlg, dce0 + i, kElemA[i]);
  739.     for (i = 1; i <= cAspect; i++)
  740.       SetEditColor(hdlg, dca1 + i - 1, kAspA[i]);
  741.     for (i = 0; i < cColor; i++) {
  742.       j = ikPalette[i];
  743.       SetEditColor(hdlg, dck0 + i, j <= 0 ? kMainA[-j] : kRainbowA[j]);
  744.     }
  745.     return fTrue;
  746.  
  747.   case WM_COMMAND:
  748.     if (wParam == IDOK) {
  749.       for (k = 0; k <= 1; k++) {
  750.         for (i = 0; i < 4; i++) {
  751.           GetEdit(dce0 + i, sz);
  752.           l = NParseSz(sz, pmColor);
  753.           if (k)
  754.             kElemA[i] = l;
  755.           else
  756.             EnsureN(l, FValidColor(l), "element color");
  757.         }
  758.         for (i = 1; i <= cAspect; i++) {
  759.           GetEdit(dca1 + i - 1, sz);
  760.           l = NParseSz(sz, pmColor);
  761.           if (k)
  762.             kAspA[i] = l;
  763.           else
  764.             EnsureN(l, FValidColor(l), "aspect color");
  765.         }
  766.         for (i = 0; i < cColor; i++) {
  767.           GetEdit(dck0 + i, sz);
  768.           l = NParseSz(sz, pmColor);
  769.           if (k) {
  770.             j = ikPalette[i];
  771.             if (j <= 0)
  772.               kMainA[-j] = l;
  773.             else
  774.               kRainbowA[j] = l;
  775.           } else
  776.             EnsureN(l, FValidColor(l), "palette color");
  777.         }
  778.       }
  779.       wi.fRedraw = fTrue;
  780.     }
  781.     if (wParam == IDOK || wParam == IDCANCEL) {
  782.       EndDialog(hdlg, fTrue);
  783.       return fTrue;
  784.     }
  785.     break;
  786.   }
  787.   return fFalse;
  788. }
  789.  
  790.  
  791. /* Processing function for the chart info entry dialog, as brought up by  */
  792. /* both the Info Set Chart Info and Info Set Chart #2 Info menu commands. */
  793.  
  794. bool API DlgInfo(hdlg, message, wParam, lParam)
  795. HWND hdlg;
  796. _int message;
  797. WORD wParam;
  798. LONG lParam;
  799. {
  800.   CI ci;
  801.   char sz[cchSzDef];
  802.  
  803.   switch (message) {
  804.   case WM_INITDIALOG:
  805.     if (wi.wCmd == cmdSetInfo)
  806.       ci = ciMain;
  807.     else {
  808.       SetWindowText(hdlg, "Enter Chart #2 Info");
  809.       ci = ciTwin;
  810.     }
  811. LInit:
  812.     SetEditMDYT(hdlg, dcInMon, dcInDay, dcInYea, dcInTim,
  813.       ci.mon, ci.day, ci.yea, ci.tim);
  814.     SetEditSZOA(hdlg, dcInDst, dcInZon, dcInLon, dcInLat,
  815.       ci.dst, ci.zon, ci.lon, ci.lat);
  816.     SetEditSz(hdlg, deInNam, ciMain.nam);
  817.     SetEditSz(hdlg, deInLoc, ciMain.loc);
  818.     SetFocus(GetDlgItem(hdlg, dcInMon));
  819.     return fFalse;
  820.  
  821.   case WM_COMMAND:
  822.     if (wParam == dbInNow || wParam == dbInSet) {
  823.       if (wParam == dbInNow) {
  824.         GetTimeNow(&ci.mon, &ci.day, &ci.yea, &ci.tim, us.zonDef-us.dstDef);
  825.         ci.dst = us.dstDef; ci.zon = us.zonDef;
  826.         ci.lon = us.lonDef; ci.lat = us.latDef;
  827.       } else
  828.         ci = ciSave;
  829.       goto LInit;
  830.     }
  831.  
  832.     if (wParam == IDOK) {
  833.       GetEdit(dcInMon, sz); ci.mon = NParseSz(sz, pmMon);
  834.       GetEdit(dcInDay, sz); ci.day = NParseSz(sz, pmDay);
  835.       GetEdit(dcInYea, sz); ci.yea = NParseSz(sz, pmYea);
  836.       GetEdit(dcInTim, sz); ci.tim = RParseSz(sz, pmTim);
  837.       GetEdit(dcInDst, sz); ci.dst = RParseSz(sz, pmDst);
  838.       GetEdit(dcInZon, sz); ci.zon = RParseSz(sz, pmZon);
  839.       GetEdit(dcInLon, sz); ci.lon = RParseSz(sz, pmLon);
  840.       GetEdit(dcInLat, sz); ci.lat = RParseSz(sz, pmLat);
  841.       EnsureN(ci.mon, FValidMon(ci.mon), "month");
  842.       EnsureN(ci.yea, FValidYea(ci.yea), "year");
  843.       EnsureN(ci.day, FValidDay(ci.day, ci.mon, ci.yea), "day");
  844.       EnsureR(ci.tim, FValidTim(ci.tim), "time");
  845.       EnsureR(ci.dst, FValidZon(ci.dst), "daylight");
  846.       EnsureR(ci.zon, FValidZon(ci.zon), "zone");
  847.       EnsureR(ci.lon, FValidLon(ci.lon), "longitude");
  848.       EnsureR(ci.lat, FValidLat(ci.lat), "latitude");
  849.       GetEdit(deInNam, sz);
  850.       ci.nam = SzPersist(sz);
  851.       GetEdit(deInLoc, sz);
  852.       ci.loc = SzPersist(sz);
  853.       if (wi.wCmd == cmdSetInfo)
  854.         ciMain = ciCore = ci;
  855.       else
  856.         ciTwin = ci;
  857.       wi.fCast = fTrue;
  858.     }
  859.     if (wParam == IDOK || wParam == IDCANCEL) {
  860.       EndDialog(hdlg, fTrue);
  861.       return fTrue;
  862.     }
  863.     break;
  864.   }
  865.   return fFalse;
  866. }
  867.  
  868.  
  869. /* Processing function for the default chart info dialog, as brought up */
  870. /* with the Info Default Chart Info menu command.                       */
  871.  
  872. bool API DlgDefault(hdlg, message, wParam, lParam)
  873. HWND hdlg;
  874. _int message;
  875. WORD wParam;
  876. LONG lParam;
  877. {
  878.   CI ci;
  879.   char sz[cchSzDef];
  880.  
  881.   switch (message) {
  882.   case WM_INITDIALOG:
  883.     SetEditSZOA(hdlg, dcDeDst, dcDeZon, dcDeLon, dcDeLat,
  884.       us.dstDef, us.zonDef, us.lonDef, us.latDef);
  885.     SetFocus(GetDlgItem(hdlg, dcDeDst));
  886.     return fFalse;
  887.  
  888.   case WM_COMMAND:
  889.     if (wParam == IDOK) {
  890.       GetEdit(dcDeDst, sz); ci.dst = RParseSz(sz, pmDst);
  891.       GetEdit(dcDeZon, sz); ci.zon = RParseSz(sz, pmZon);
  892.       GetEdit(dcDeLon, sz); ci.lon = RParseSz(sz, pmLon);
  893.       GetEdit(dcDeLat, sz); ci.lat = RParseSz(sz, pmLat);
  894.       EnsureR(ci.dst, FValidZon(ci.dst), "daylight");
  895.       EnsureR(ci.zon, FValidZon(ci.zon), "zone");
  896.       EnsureR(ci.lon, FValidLon(ci.lon), "longitude");
  897.       EnsureR(ci.lat, FValidLat(ci.lat), "latitude");
  898.       us.dstDef = ci.dst; us.zonDef = ci.zon;
  899.       us.lonDef = ci.lon; us.latDef = ci.lat;
  900.       wi.fCast = fTrue;
  901.     }
  902.     if (wParam == IDOK || wParam == IDCANCEL) {
  903.       EndDialog(hdlg, fTrue);
  904.       return fTrue;
  905.     }
  906.     break;
  907.   }
  908.   return fFalse;
  909. }
  910.  
  911.  
  912. /* Processing function for the aspect settings dialog, as brought up with */
  913. /* the Setting Aspect Settings menu command.                              */
  914.  
  915. bool API DlgAspect(hdlg, message, wParam, lParam)
  916. HWND hdlg;
  917. _int message;
  918. WORD wParam;
  919. LONG lParam;
  920. {
  921.   int i, j;
  922.   real r;
  923.  
  924.   switch (message) {
  925.   case WM_INITDIALOG:
  926.     for (i = 1; i <= cAspect; i++) {
  927.       SetCheck(dxa1 - 1 + i, i > us.nAsp);
  928.       SetEditR(hdlg, deo1 - 1 + i, rAspOrb[i], 2);
  929.       SetEditR(hdlg, dea1 - 1 + i, rAspAngle[i], 6);
  930.       SetEditR(hdlg, dei1 - 1 + i, rAspInf[i], 2);
  931.     }
  932.     return fTrue;
  933.  
  934.   case WM_COMMAND:
  935.     switch (wParam) {
  936.     case dbAs_RA0:
  937.       for (i = 1; i <= cAspect; i++)
  938.         SetCheck(dxa1 - 1 + i, fTrue);
  939.       break;
  940.     case dbAs_RA1:
  941.       for (i = 1; i <= cAspect; i++)
  942.         SetCheck(dxa1 - 1 + i, fFalse);
  943.       break;
  944.     case dbAs_RA:
  945.       for (i = 1; i <= 5; i++)
  946.         SetCheck(dxa1 - 1 + i, !GetCheck(dxa1 - 1 + i));
  947.       break;
  948.     }
  949.  
  950.     if (wParam == IDOK) {
  951.       for (j = 0; j <= 1; j++) {
  952.         for (i = 1; i <= cAspect; i++) {
  953.           r = GetEditR(hdlg, deo1 - 1 + i);
  954.           if (j)
  955.             rAspOrb[i] = r;
  956.           else
  957.             EnsureR(r, r >= -rDegMax && r <= rDegMax, "orb");
  958.         }
  959.         for (i = 1; i <= cAspect; i++) {
  960.           r = GetEditR(hdlg, dea1 - 1 + i);
  961.           if (j)
  962.             rAspAngle[i] = r;
  963.           else
  964.             EnsureR(r, r >= -rDegMax && r <= rDegMax, "angle");
  965.         }
  966.         for (i = 1; i <= cAspect; i++) {
  967.           r = GetEditR(hdlg, dei1 - 1 + i);
  968.           if (j)
  969.             rAspInf[i] = r;
  970.         }
  971.       }
  972.       for (us.nAsp = cAspect; us.nAsp > 0 && GetCheck(dxa1 - 1 + us.nAsp);
  973.         us.nAsp--)
  974.         ;
  975.       for (i = 1; i <= us.nAsp; i++) {
  976.         if (GetCheck(dxa1 - 1 + i))
  977.           rAspOrb[i] = -rDegHalf;
  978.       }
  979.       wi.fRedraw = fTrue;
  980.     }
  981.     if (wParam == IDOK || wParam == IDCANCEL) {
  982.       EndDialog(hdlg, fTrue);
  983.       return fTrue;
  984.     }
  985.     break;
  986.   }
  987.   return fFalse;
  988. }
  989.  
  990.  
  991. /* Processing function for the object settings dialog, as brought up with */
  992. /* the Setting Object Settings menu command.                              */
  993.  
  994. bool API DlgObject(hdlg, message, wParam, lParam)
  995. HWND hdlg;
  996. _int message;
  997. WORD wParam;
  998. LONG lParam;
  999. {
  1000.   int i, j;
  1001.   real r;
  1002.  
  1003.   switch (message) {
  1004.   case WM_INITDIALOG:
  1005.     for (i = 1; i <= oCore; i++) {
  1006.       SetEditR(hdlg, deo1 - 1 + i, rObjOrb[i], 2);
  1007.       SetEditR(hdlg, dea1 - 1 + i, rObjAdd[i], 1);
  1008.       SetEditR(hdlg, dei1 - 1 + i, rObjInf[i], 2);
  1009.     }
  1010.     return fTrue;
  1011.  
  1012.   case WM_COMMAND:
  1013.     if (wParam == IDOK) {
  1014.       for (j = 0; j <= 1; j++) {
  1015.         for (i = 1; i <= oCore; i++) {
  1016.           r = GetEditR(hdlg, deo1 - 1 + i);
  1017.           if (j)
  1018.             rObjOrb[i] = r;
  1019.           else
  1020.             EnsureR(r, r >= -rDegMax && r <= rDegMax, "max orb");
  1021.         }
  1022.         for (i = 1; i <= oCore; i++) {
  1023.           r = GetEditR(hdlg, dea1 - 1 + i);
  1024.           if (j)
  1025.             rObjAdd[i] = r;
  1026.           else
  1027.             EnsureR(r, r >= -rDegMax && r <= rDegMax, "orb addition");
  1028.         }
  1029.         for (i = 1; i <= oCore; i++) {
  1030.           r = GetEditR(hdlg, dei1 - 1 + i);
  1031.           if (j)
  1032.             rObjInf[i] = r;
  1033.         }
  1034.       }
  1035.       wi.fRedraw = fTrue;
  1036.     }
  1037.     if (wParam == IDOK || wParam == IDCANCEL) {
  1038.       EndDialog(hdlg, fTrue);
  1039.       return fTrue;
  1040.     }
  1041.     break;
  1042.   }
  1043.   return fFalse;
  1044. }
  1045.  
  1046.  
  1047. /* Processing function for the cuap and uranian object settings dialog, as */
  1048. /* brought up with the Setting More Object Settings menu command.          */
  1049.  
  1050. bool API DlgObject2(hdlg, message, wParam, lParam)
  1051. HWND hdlg;
  1052. _int message;
  1053. WORD wParam;
  1054. LONG lParam;
  1055. {
  1056.   int i, j;
  1057.   real r;
  1058.  
  1059.   switch (message) {
  1060.   case WM_INITDIALOG:
  1061.     for (i = oAsc; i <= uranHi; i++) {
  1062.       SetEditR(hdlg, deo1 - oAsc + i, rObjOrb[i], 2);
  1063.       SetEditR(hdlg, dea1 - oAsc + i, rObjAdd[i], 1);
  1064.       SetEditR(hdlg, dei1 - oAsc + i, rObjInf[i], 2);
  1065.     }
  1066.     return fTrue;
  1067.  
  1068.   case WM_COMMAND:
  1069.     if (wParam == IDOK) {
  1070.       for (j = 0; j <= 1; j++) {
  1071.         for (i = oAsc; i <= uranHi; i++) {
  1072.           r = GetEditR(hdlg, deo1 - oAsc + i);
  1073.           if (j)
  1074.             rObjOrb[i] = r;
  1075.           else
  1076.             EnsureR(r, r >= -rDegMax && r <= rDegMax, "max orb");
  1077.         }
  1078.         for (i = oAsc; i <= uranHi; i++) {
  1079.           r = GetEditR(hdlg, dea1 - oAsc + i);
  1080.           if (j)
  1081.             rObjAdd[i] = r;
  1082.           else
  1083.             EnsureR(r, r >= -rDegMax && r <= rDegMax, "orb addition");
  1084.         }
  1085.         for (i = oAsc; i <= uranHi; i++) {
  1086.           r = GetEditR(hdlg, dei1 - oAsc + i);
  1087.           if (j)
  1088.             rObjInf[i] = r;
  1089.         }
  1090.       }
  1091.       wi.fRedraw = fTrue;
  1092.     }
  1093.     if (wParam == IDOK || wParam == IDCANCEL) {
  1094.       EndDialog(hdlg, fTrue);
  1095.       return fTrue;
  1096.     }
  1097.     break;
  1098.   }
  1099.   return fFalse;
  1100. }
  1101.  
  1102.  
  1103. /* Processing function for the object restrictions dialog, as invoked with */
  1104. /* both the Setting Restrictions and Transit Restrictions menu commands.   */
  1105.  
  1106. bool API DlgRestrict(hdlg, message, wParam, lParam)
  1107. HWND hdlg;
  1108. _int message;
  1109. WORD wParam;
  1110. LONG lParam;
  1111. {
  1112.   byte *lpb, *lpb2;
  1113.   int i;
  1114.  
  1115.   switch (message) {
  1116.   case WM_INITDIALOG:
  1117.     if (wi.wCmd == cmdRes)
  1118.       lpb = ignore;
  1119.     else {
  1120.       SetWindowText(hdlg, "Transit Object Restrictions");
  1121.       lpb = ignore2;
  1122.     }
  1123.     for (i = 1; i <= oNorm; i++)
  1124.       SetCheck(dx1 - 1 + i, lpb[i]);
  1125.     return fTrue;
  1126.  
  1127.   case WM_COMMAND:
  1128.     switch (wParam) {
  1129.     case dbRe_R0:
  1130.       for (i = 1; i <= oNorm; i++)
  1131.         SetCheck(dx1 - 1 + i, fTrue);
  1132.       break;
  1133.     case dbRe_R1:
  1134.       for (i = 1; i <= oNorm; i++)
  1135.         SetCheck(dx1 - 1 + i, fFalse);
  1136.       break;
  1137.     case dbRe_R:
  1138.       for (i = oMain+1; i <= oCore; i++)
  1139.         SetCheck(dx1 - 1 + i, !GetCheck(dx1 - 1 + i));
  1140.       break;
  1141.     case dbRe_RC:
  1142.       for (i = cuspLo; i <= cuspHi; i++)
  1143.         SetCheck(dx1 - 1 + i, !GetCheck(dx1 - 1 + i));
  1144.       break;
  1145.     case dbRe_Ru:
  1146.       for (i = uranLo; i <= uranHi; i++)
  1147.         SetCheck(dx1 - 1 + i, !GetCheck(dx1 - 1 + i));
  1148.       break;
  1149.     case dbRT:
  1150.       lpb2 = wi.wCmd == cmdRes ? ignore2 : ignore;
  1151.       for (i = 1; i <= oNorm; i++)
  1152.         SetCheck(dx1 - 1 + i, lpb2[i]);
  1153.       break;
  1154.     }
  1155.  
  1156.     if (wParam == IDOK) {
  1157.       lpb = wi.wCmd == cmdRes ? ignore : ignore2;
  1158.       for (i = 1; i <= oNorm; i++)
  1159.         lpb[i] = GetCheck(dx1 - 1 + i);
  1160.       if (!us.fCusp) {
  1161.         for (i = cuspLo; i <= cuspHi; i++)
  1162.           if (!lpb[i]) {
  1163.             us.fCusp = fTrue;
  1164.             WiCheckMenu(cmdResCusp, fTrue);
  1165.             break;
  1166.           }
  1167.       } else {
  1168.         for (i = cuspLo; i <= cuspHi; i++)
  1169.           if (!lpb[i])
  1170.             break;
  1171.         if (i > cuspHi) {
  1172.           us.fCusp = fFalse;
  1173.           WiCheckMenu(cmdResCusp, fFalse);
  1174.         }
  1175.       }
  1176.       if (!us.fUranian) {
  1177.         for (i = uranLo; i <= uranHi; i++)
  1178.           if (!lpb[i]) {
  1179.             us.fUranian = fTrue;
  1180.             WiCheckMenu(cmdResUranian, fTrue);
  1181.             break;
  1182.           }
  1183.       } else {
  1184.         for (i = uranLo; i <= uranHi; i++)
  1185.           if (!lpb[i])
  1186.             break;
  1187.         if (i > uranHi) {
  1188.           us.fUranian = fFalse;
  1189.           WiCheckMenu(cmdResUranian, fFalse);
  1190.         }
  1191.       }
  1192.       wi.fCast = fTrue;
  1193.     }
  1194.     if (wParam == IDOK || wParam == IDCANCEL) {
  1195.       EndDialog(hdlg, fTrue);
  1196.       return fTrue;
  1197.     }
  1198.     break;
  1199.   }
  1200.   return fFalse;
  1201. }
  1202.  
  1203.  
  1204. /* Processing function for the star restrictions dialog, as brought up with */
  1205. /* the Setting Star Restrictions menu command.                              */
  1206.  
  1207. bool API DlgStar(hdlg, message, wParam, lParam)
  1208. HWND hdlg;
  1209. _int message;
  1210. WORD wParam;
  1211. LONG lParam;
  1212. {
  1213.   int i;
  1214.  
  1215.   switch (message) {
  1216.   case WM_INITDIALOG:
  1217.     for (i = 1; i <= cStar; i++)
  1218.       SetCheck(dx1 - 1 + i, ignore[oNorm + i]);
  1219.     return fTrue;
  1220.  
  1221.   case WM_COMMAND:
  1222.     switch (wParam) {
  1223.     case dbSt_RU0:
  1224.       for (i = 1; i <= cStar; i++)
  1225.         SetCheck(dx1 - 1 + i, fTrue);
  1226.       break;
  1227.     case dbSt_RU1:
  1228.       for (i = 1; i <= cStar; i++)
  1229.         SetCheck(dx1 - 1 + i, fFalse);
  1230.       break;
  1231.     }
  1232.  
  1233.     if (wParam == IDOK) {
  1234.       for (i = 1; i <= cStar; i++)
  1235.         ignore[oNorm + i] = GetCheck(dx1 - 1 + i);
  1236.       if (!us.nStar) {
  1237.         for (i = starLo; i <= starHi; i++)
  1238.           if (!ignore[i]) {
  1239.             us.nStar = fTrue;
  1240.             WiCheckMenu(cmdResStar, fTrue);
  1241.             break;
  1242.           }
  1243.       } else {
  1244.         for (i = starLo; i <= starHi; i++)
  1245.           if (!ignore[i])
  1246.             break;
  1247.         if (i > starHi) {
  1248.           us.nStar = fFalse;
  1249.           WiCheckMenu(cmdResStar, fFalse);
  1250.         }
  1251.       }
  1252.       wi.fCast = fTrue;
  1253.     }
  1254.     if (wParam == IDOK || wParam == IDCANCEL) {
  1255.       EndDialog(hdlg, fTrue);
  1256.       return fTrue;
  1257.     }
  1258.     break;
  1259.   }
  1260.   return fFalse;
  1261. }
  1262.  
  1263.  
  1264. /* Processing function for the standard settings dialog, as brought up with */
  1265. /* the Setting More Settings menu command.                                  */
  1266.  
  1267. bool API DlgSetting(hdlg, message, wParam, lParam)
  1268. HWND hdlg;
  1269. _int message;
  1270. WORD wParam;
  1271. LONG lParam;
  1272. {
  1273.   char sz[cchSzDef];
  1274.   real r1;
  1275.   int n2, n3, n4, n5, n6;
  1276.  
  1277.   switch (message) {
  1278.   case WM_INITDIALOG:
  1279.     SetEditR(hdlg, deSe_s, us.rZodiacOffset, 6);
  1280.     SetEditN(deSe_A, us.nAsp);
  1281.     SetEditN(deSe_x, us.nHarmonic);
  1282.     SetEdit(deSe_h,
  1283.       szObjName[us.objCenter <= 1 ? 1-us.objCenter : us.objCenter]);
  1284.     SetRadio(us.objOnAsc == 0 ? dr1 : (us.objOnAsc > 0 ? dr2 : dr3),
  1285.       dr1, dr3);
  1286.     SetEdit(deSe_1, szObjName[us.objOnAsc == 0 ? oSun : abs(us.objOnAsc)]);
  1287.     SetEditN(deSe_I, us.nScreenWidth);
  1288.     SetCheck(dxSe_b, us.fPlacalc);
  1289.     SetRadio(us.nDegForm == 0 ? dr4 : (us.nDegForm == 1 ? dr5 : dr6),
  1290.       dr4, dr6);
  1291.     SetCheck(dxSe_sr, us.fEquator);
  1292.     return fTrue;
  1293.  
  1294.   case WM_COMMAND:
  1295.     if (wParam == IDOK) {
  1296.       r1 = GetEditR(hdlg, deSe_s);
  1297.       GetEdit(deSe_A, sz); n2 = NParseSz(sz, pmAspect);
  1298.       n3 = GetEditN(deSe_x);
  1299.       GetEdit(deSe_h, sz); n4 = NParseSz(sz, pmObject);
  1300.       GetEdit(deSe_1, sz); n5 = NParseSz(sz, pmObject);
  1301.       n6 = GetEditN(deSe_I);
  1302.       EnsureR(r1, FValidOffset(r1), "zodiac offset");
  1303.       EnsureN(n2, FValidAspect(n2), "aspect count");
  1304.       EnsureN(n3, FValidHarmonic(n3), "harmonic factor");
  1305.       EnsureN(n4, FValidCenter(n4), "central planet");
  1306.       EnsureN(n5, FItem(n5), "Solar chart planet");
  1307.       EnsureN(n6, FValidScreen(n6), "text columns");
  1308.       us.rZodiacOffset = r1;
  1309.       us.nAsp = n2;
  1310.       us.nHarmonic = n3;
  1311.       us.objCenter = n4 <= 1 ? 1-n4 : n4;
  1312.       us.objOnAsc = GetCheck(dr1) ? 0 : (GetCheck(dr2) ? n5 : -n5);
  1313.       us.nScreenWidth = n6;
  1314.       us.fPlacalc = GetCheck(dxSe_b);
  1315.       us.nDegForm = GetCheck(dr4) ? 0 : (GetCheck(dr5) ? 1 : 2);
  1316.       us.fEquator = GetCheck(dxSe_sr);
  1317.       WiCheckMenu(cmdHeliocentric, us.objCenter != 1);
  1318.       wi.fCast = fTrue;
  1319.     }
  1320.     if (wParam == IDOK || wParam == IDCANCEL) {
  1321.       EndDialog(hdlg, fTrue);
  1322.       return fTrue;
  1323.     }
  1324.     break;
  1325.   }
  1326.   return fFalse;
  1327. }
  1328.  
  1329.  
  1330. /* Processing function for the obscure settings dialog, as brought up with */
  1331. /* the Setting Obscure Settings menu command.                              */
  1332.  
  1333. bool API DlgObscure(hdlg, message, wParam, lParam)
  1334. HWND hdlg;
  1335. _int message;
  1336. WORD wParam;
  1337. LONG lParam;
  1338. {
  1339.   int n1;
  1340.  
  1341.   switch (message) {
  1342.   case WM_INITDIALOG:
  1343.     SetCheck(dxOb_Yn, us.fTrueNode);
  1344.     SetCheck(dxOb_Yd, us.fEuroDate);
  1345.     SetCheck(dxOb_Yt, us.fEuroTime);
  1346.     SetCheck(dxOb_YC, us.fSmartCusp);
  1347.     SetCheck(dxOb_Y8, us.fClip80);
  1348.     SetCheck(dxOb_Yo, us.fWriteOld);
  1349.     SetCheck(dxOb_Yc0, us.fHouseAngle);
  1350.     SetCheck(dxOb_YR0_s, ignore[0]);
  1351.     SetCheck(dxOb_YR0_d, ignore2[0]);
  1352.     SetEditN(deOb_YXg, gs.nGridCell);
  1353.     SetCheck(dxOb_YXf, gs.fFont);
  1354.     SetEditR(hdlg, deOb_YXp0_x, gs.xInch, 2);
  1355.     SetEditR(hdlg, deOb_YXp0_y, gs.yInch, 2);
  1356.     SetRadio(gs.nOrient == 0 ? dr11 : (gs.nOrient > 0 ? dr9 : dr10),
  1357.       dr9, dr11);
  1358.     SetRadio(dr1 + (gs.nGlyphs/1000 == 2), dr1, dr2);
  1359.     SetRadio(dr3 + ((gs.nGlyphs/100)%10 == 2), dr3, dr4);
  1360.     SetRadio(dr5 + ((gs.nGlyphs/10)%10 == 2), dr5, dr6);
  1361.     SetRadio(dr7 + (gs.nGlyphs%10 == 2), dr7, dr8);
  1362.     return fTrue;
  1363.  
  1364.   case WM_COMMAND:
  1365.     if (wParam == IDOK) {
  1366.       n1 = GetEditN(deOb_YXg);
  1367.       EnsureN(n1, FValidGrid(n1), "grid cell");
  1368.       us.fTrueNode = GetCheck(dxOb_Yn);
  1369.       us.fEuroDate = GetCheck(dxOb_Yd);
  1370.       us.fEuroTime = GetCheck(dxOb_Yt);
  1371.       us.fSmartCusp = GetCheck(dxOb_YC);
  1372.       us.fClip80 = GetCheck(dxOb_Y8);
  1373.       us.fWriteOld = GetCheck(dxOb_Yo);
  1374.       us.fHouseAngle = GetCheck(dxOb_Yc0);
  1375.       ignore[0] = GetCheck(dxOb_YR0_s);
  1376.       ignore2[0] = GetCheck(dxOb_YR0_d);
  1377.       gs.nGridCell = n1;
  1378.       gs.fFont = GetCheck(dxOb_YXf);
  1379.       gs.xInch = GetEditR(hdlg, deOb_YXp0_x);
  1380.       gs.yInch = GetEditR(hdlg, deOb_YXp0_y);
  1381.       gs.nOrient = GetCheck(dr11) ? 0 : (GetCheck(dr9) ? 1 : -1);
  1382.       gs.nGlyphs = (GetCheck(dr1) ? 1 : 2) * 1000 + (GetCheck(dr3) ? 1 : 2) *
  1383.         100 + (GetCheck(dr5) ? 1 : 2) * 10 + (GetCheck(dr7) ? 1 : 2);
  1384.       wi.fCast = fTrue;
  1385.     }
  1386.     if (wParam == IDOK || wParam == IDCANCEL) {
  1387.       EndDialog(hdlg, fTrue);
  1388.       return fTrue;
  1389.     }
  1390.     break;
  1391.   }
  1392.   return fFalse;
  1393. }
  1394.  
  1395.  
  1396. /* Processing function for the transit chart dialog, as brought up with the */
  1397. /* Chart Transits menu command.                                             */
  1398.  
  1399. bool API DlgTransit(hdlg, message, wParam, lParam)
  1400. HWND hdlg;
  1401. _int message;
  1402. WORD wParam;
  1403. LONG lParam;
  1404. {
  1405.   char sz[cchSzDef];
  1406.   int mon, day, yea, n1, n2;
  1407.   real tim;
  1408.  
  1409.   switch (message) {
  1410.   case WM_INITDIALOG:
  1411.     if (us.fInDay)           n1 = 1;
  1412.     else if (us.fInDayInf)   n1 = 2;
  1413.     else if (us.fTransit)    n1 = 3;
  1414.     else if (us.fTransitInf) n1 = 4;
  1415.     else                     n1 = 0;
  1416.     SetRadio(dr1 + n1, dr1, dr5);
  1417.     SetCheck(dxTr_p, is.fProgress);
  1418.     SetEditMDYT(hdlg, dcTrMon, dcTrDay, dcTrYea, dcTrTim,
  1419.       Mon2, Day2, Yea2, Tim2);
  1420.     if (n1 == 1) {
  1421.       n2 = is.fProgress || us.fInDayMonth;
  1422.       if (n2 == 1 && Mon2 == 0)
  1423.         n2 += 1 + (us.nEphemYears > 1);
  1424.     } else if (n1 == 3)
  1425.       n2 = 1 + (Mon2 <= 0) + (Mon2 < 0);
  1426.     else
  1427.       n2 = 0;
  1428.     SetRadio(dr6 + n2, dr6, dr9);
  1429.     SetEditN(deTr_tY, us.nEphemYears);
  1430.     SetEditN(deTr_d, us.nDivision);
  1431.     SetFocus(GetDlgItem(hdlg, dcTrMon));
  1432.     return fFalse;
  1433.  
  1434.   case WM_COMMAND:
  1435.     if (wParam == dbTr_tn) {
  1436.       GetTimeNow(&mon, &day, &yea, &tim, us.zonDef-us.dstDef);
  1437.       SetEditMDYT(hdlg, dcTrMon, dcTrDay, dcTrYea, dcTrTim,
  1438.         mon, day, yea, tim);
  1439.     }
  1440.  
  1441.     if (wParam == IDOK) {
  1442.       GetEdit(dcTrMon, sz); mon = NParseSz(sz, pmMon);
  1443.       GetEdit(dcTrDay, sz); day = NParseSz(sz, pmDay);
  1444.       GetEdit(dcTrYea, sz); yea = NParseSz(sz, pmYea);
  1445.       GetEdit(dcTrTim, sz); tim = RParseSz(sz, pmTim);
  1446.       n1 = GetEditN(deTr_tY);
  1447.       n2 = GetEditN(deTr_d);
  1448.       EnsureN(mon, FValidMon(mon), "month");
  1449.       EnsureN(yea, FValidYea(yea), "year");
  1450.       EnsureN(day, FValidDay(day, mon, yea), "day");
  1451.       EnsureR(tim, FValidTim(tim), "time");
  1452.       EnsureN(n2, FValidDivision(n2), "searching divisions");
  1453.       Mon2 = mon; Day2 = day; Yea2 = yea; Tim2 = tim;
  1454.       us.nEphemYears = n1;
  1455.       us.nDivision = n2;
  1456.       is.fProgress = GetCheck(dxTr_p);
  1457.       n1 = GetCheck(dr1) ? 0 : (GetCheck(dr2) ? 1 : (GetCheck(dr3) ? 2 :
  1458.         (GetCheck(dr4) ? 3 : 4)));
  1459.       switch (n1) {
  1460.       case 1: wi.nMode = gTraTraHit; break;
  1461.       case 2: wi.nMode = gTraTraInf; break;
  1462.       case 3: wi.nMode = gTraNatHit; break;
  1463.       case 4: wi.nMode = gTraNatInf; break;
  1464.       default: wi.nMode = gWheel;
  1465.       }
  1466.       n2 = GetCheck(dr6) ? 0 : (GetCheck(dr7) ? 1 : (GetCheck(dr8) ? 2 : 3));
  1467.       if (n1 == 1) {
  1468.         us.fInDayMonth = (is.fProgress || n2 >= 1);
  1469.         if (n2 >= 2) {
  1470.           Mon2 = 0;
  1471.           if (n2 == 2)
  1472.             us.nEphemYears = 1;
  1473.         }
  1474.       } else if (n1 == 3) {
  1475.         if (n2 == 2)
  1476.           Mon2 = 0;
  1477.         else if (n2 == 3) {
  1478.           Mon2 = -1; Day2 = us.nEphemYears;
  1479.         }
  1480.       } else if (n1 == 2) {
  1481.         us.fProgress = is.fProgress;
  1482.         wi.fCast = fTrue;
  1483.       }
  1484.       us.fGraphics = fFalse;
  1485.       wi.fRedraw = fTrue;
  1486.     }
  1487.     if (wParam == IDOK || wParam == IDCANCEL) {
  1488.       EndDialog(hdlg, fTrue);
  1489.       return fTrue;
  1490.     }
  1491.     break;
  1492.   }
  1493.   return fFalse;
  1494. }
  1495.  
  1496.  
  1497. /* Processing function for the progression settings dialog, as brought up */
  1498. /* with the Chart Progressions menu command.                              */
  1499.  
  1500. bool API DlgProgress(hdlg, message, wParam, lParam)
  1501. HWND hdlg;
  1502. _int message;
  1503. WORD wParam;
  1504. LONG lParam;
  1505. {
  1506.   char sz[cchSzDef];
  1507.   int mon, day, yea;
  1508.   real tim, r1;
  1509.  
  1510.   switch (message) {
  1511.   case WM_INITDIALOG:
  1512.     SetCheck(dxPr_p, us.fProgress);
  1513.     SetEditMDYT(hdlg, dcPrMon, dcPrDay, dcPrYea, dcPrTim,
  1514.       Mon2, Day2, Yea2, Tim2);
  1515.     SetRadio(dr1 + us.fSolarArc, dr1, dr2);
  1516.     SetEditR(hdlg, dcPr_pd, us.rProgDay, 5);
  1517.     SetCombo(dcPr_pd, "365.25");
  1518.     SetCombo(dcPr_pd, "27.321661");
  1519.     SetCombo(dcPr_pd, "29.530588");
  1520.     SetFocus(GetDlgItem(hdlg, dcPrMon));
  1521.     return fFalse;
  1522.  
  1523.   case WM_COMMAND:
  1524.     if (wParam == dbPr_pn) {
  1525.       GetTimeNow(&mon, &day, &yea, &tim, us.zonDef-us.dstDef);
  1526.       SetEditMDYT(hdlg, dcPrMon, dcPrDay, dcPrYea, dcPrTim,
  1527.         mon, day, yea, tim);
  1528.     }
  1529.  
  1530.     if (wParam == IDOK) {
  1531.       GetEdit(dcPrMon, sz); mon = NParseSz(sz, pmMon);
  1532.       GetEdit(dcPrDay, sz); day = NParseSz(sz, pmDay);
  1533.       GetEdit(dcPrYea, sz); yea = NParseSz(sz, pmYea);
  1534.       GetEdit(dcPrTim, sz); tim = RParseSz(sz, pmTim);
  1535.       r1 = GetEditR(hdlg, dcPr_pd);
  1536.       EnsureN(mon, FValidMon(mon), "month");
  1537.       EnsureN(yea, FValidYea(yea), "year");
  1538.       EnsureN(day, FValidDay(day, mon, yea), "day");
  1539.       EnsureR(tim, FValidTim(tim), "time");
  1540.       EnsureR(r1, r1 != 0.0, "degree per day");
  1541.       Mon2 = mon; Day2 = day; Yea2 = yea; Tim2 = tim;
  1542.       us.rProgDay = r1;
  1543.       us.fProgress = GetCheck(dxPr_p);
  1544.       us.fSolarArc = GetCheck(dr2);
  1545.       is.JDp = MdytszToJulian(Mon2, Day2, Yea2, Tim2, us.dstDef, us.zonDef);
  1546.       wi.fCast = fTrue;
  1547.     }
  1548.     if (wParam == IDOK || wParam == IDCANCEL) {
  1549.       EndDialog(hdlg, fTrue);
  1550.       return fTrue;
  1551.     }
  1552.     break;
  1553.   }
  1554.   return fFalse;
  1555. }
  1556.  
  1557.  
  1558. /* Processing function for the chart subsettings dialog, as brought up with */
  1559. /* the Chart Chart Settings menu command.                                   */
  1560.  
  1561. bool API DlgChart(hdlg, message, wParam, lParam)
  1562. HWND hdlg;
  1563. _int message;
  1564. WORD wParam;
  1565. LONG lParam;
  1566. {
  1567.   int n1, n2, n3;
  1568.   bool f;
  1569.  
  1570.   switch (message) {
  1571.   case WM_INITDIALOG:
  1572.     SetCheck(dxCh_v0, us.fVelocity);
  1573.     SetEditN(deCh_w, us.nWheelRows);
  1574.     SetCheck(dxCh_w0, us.fWheelReverse);
  1575.     SetCheck(dxCh_g0, us.fGridConfig);
  1576.     SetCheck(dxCh_a0, us.fAspSummary);
  1577.     SetCheck(dxCh_m0, us.fMidSummary);
  1578.     SetCheck(dxCh_ma, us.fMidAspect);
  1579.     SetCheck(dxCh_Z0, us.fPrimeVert);
  1580.     SetCheck(dxCh_j0, us.fInfluenceSign);
  1581.     SetEditN(deCh_L, us.nAstroGraphStep);
  1582.     SetCheck(dxCh_L0, us.fLatitudeCross);
  1583.     SetCheck(dxCh_Ky, us.fCalendarYear);
  1584.     SetEditN(deCh_P, us.nArabicParts);
  1585.     SetCheck(dxCh_P0, us.fArabicFlip);
  1586.     switch (us.nStar) {
  1587.     case 'z': n1 = dr2; break;
  1588.     case 'l': n1 = dr3; break;
  1589.     case 'n': n1 = dr4; break;
  1590.     case 'b': n1 = dr5; break;
  1591.     default:  n1 = dr1;
  1592.     }
  1593.     SetRadio(n1, dr1, dr5);
  1594.     switch (us.nArabic) {
  1595.     case 'z': n2 = dr7; break;
  1596.     case 'n': n2 = dr8; break;
  1597.     case 'f': n2 = dr9; break;
  1598.     default:  n2 = dr6;
  1599.     }
  1600.     SetRadio(n2, dr6, dr9);
  1601.     return fTrue;
  1602.  
  1603.   case WM_COMMAND:
  1604.     if (wParam == IDOK) {
  1605.       n1 = GetEditN(deCh_w);
  1606.       n2 = GetEditN(deCh_L);
  1607.       n3 = GetEditN(deCh_P);
  1608.       EnsureN(n1, FValidWheel(n1), "wheel row");
  1609.       EnsureN(n2, FValidAstrograph(n2), "astro-graph step");
  1610.       EnsureN(n3, FValidPart(n3), "Arabic part");
  1611.       f = GetCheck(dxCh_v0);
  1612.       if (us.fVelocity != f) {
  1613.         us.fVelocity = f;
  1614.         WiCheckMenu(cmdGraphicsSidebar, !f);
  1615.       }
  1616.       us.nWheelRows = n1;
  1617.       us.fWheelReverse = GetCheck(dxCh_w0);
  1618.       us.fGridConfig = GetCheck(dxCh_g0);
  1619.       us.fAspSummary = GetCheck(dxCh_a0);
  1620.       us.fMidSummary = GetCheck(dxCh_m0);
  1621.       us.fMidAspect = GetCheck(dxCh_ma);
  1622.       us.fPrimeVert = GetCheck(dxCh_Z0);
  1623.       us.fInfluenceSign = GetCheck(dxCh_j0);
  1624.       us.nAstroGraphStep = n2;
  1625.       us.fLatitudeCross = GetCheck(dxCh_L0);
  1626.       us.fCalendarYear = GetCheck(dxCh_Ky);
  1627.       us.nArabicParts = n3;
  1628.       us.fArabicFlip = GetCheck(dxCh_P0);
  1629.       if (us.nStar)
  1630.         us.nStar = GetCheck(dr2) ? 'z' : (GetCheck(dr3) ? 'l' :
  1631.           (GetCheck(dr4) ? 'n' : (GetCheck(dr5) ? 'b' : fTrue)));
  1632.       if (us.nArabic)
  1633.         us.nArabic = GetCheck(dr7) ? 'z' : (GetCheck(dr8) ? 'n' :
  1634.           (GetCheck(dr9) ? 'f' : fTrue));
  1635.       wi.fCast = fTrue;
  1636.     }
  1637.     if (wParam == IDOK || wParam == IDCANCEL) {
  1638.       EndDialog(hdlg, fTrue);
  1639.       return fTrue;
  1640.     }
  1641.     break;
  1642.   }
  1643.   return fFalse;
  1644. }
  1645.  
  1646.  
  1647. /* Processing function for the graphic settings dialog, as brought up with */
  1648. /* the Graphics Graphics Settings menu command.                            */
  1649.  
  1650. bool API DlgGraphics(hdlg, message, wParam, lParam)
  1651. HWND hdlg;
  1652. _int message;
  1653. WORD wParam;
  1654. LONG lParam;
  1655. {
  1656.   char sz[cchSzDef];
  1657.   int n1, n2, n3, n5, n6;
  1658.   real r4;
  1659.  
  1660.   switch (message) {
  1661.   case WM_INITDIALOG:
  1662.     SetEditN(deGr_Xw_x, gs.xWin);
  1663.     SetEditN(deGr_Xw_y, gs.yWin);
  1664.     SetEditN(deGr_XW, gs.nRot);
  1665.     SetEditR(hdlg, deGr_XG, gs.rTilt, 2);
  1666.     SetCheck(dxGr_XW0, gs.fMollewide);
  1667.     SetEditN(deGr_WN, wi.nTimerDelay);
  1668.     SetRadio(gs.objLeft > 0 ? dr2 : (gs.objLeft < 0 ? dr3 : dr1), dr1, dr3);
  1669.     SetEdit(deGr_X1, szObjName[gs.objLeft == 0 ? oSun : abs(gs.objLeft)]);
  1670.     return fTrue;
  1671.  
  1672.   case WM_COMMAND:
  1673.     if (wParam == IDOK) {
  1674.       n1 = GetEditN(deGr_Xw_x);
  1675.       n2 = GetEditN(deGr_Xw_y);
  1676.       n3 = GetEditN(deGr_XW);
  1677.       r4 = GetEditR(hdlg, deGr_XG);
  1678.       n5 = GetEditN(deGr_WN);
  1679.       GetEdit(deGr_X1, sz); n6 = NParseSz(sz, pmObject);
  1680.       EnsureN(n1, FValidGraphx(n1), "horizontal size");
  1681.       EnsureN(n2, FValidGraphy(n2), "vertical size");
  1682.       EnsureN(n3, FValidRotation(n3), "horizontal rotation");
  1683.       EnsureR(r4, FValidTilt(r4), "vertical tilt");
  1684.       EnsureN(n5, FValidTimer(n5), "animation delay");
  1685.       EnsureN(n5, FItem(n6), "rotation planet");
  1686.       if (gs.xWin != n1 || gs.yWin != n2) {
  1687.         gs.xWin = n1; gs.yWin = n2;
  1688.         if (wi.fWindowChart)
  1689.           ResizeWindowToChart();
  1690.       }
  1691.       gs.nRot = n3; gs.rTilt = r4;
  1692.       if (wi.nTimerDelay != (UINT)n5) {
  1693.         wi.nTimerDelay = n5;
  1694.         if (wi.nTimer != 0)
  1695.           KillTimer(wi.hwnd, 1);
  1696.         wi.nTimer = SetTimer(wi.hwnd, 1, wi.nTimerDelay, NULL);
  1697.       }
  1698.       gs.objLeft = GetCheck(dr1) ? 0 : (GetCheck(dr2) ? n6 : -n6);
  1699.       gs.fMollewide = GetCheck(dxGr_XW0);
  1700.       us.fGraphics = wi.fRedraw = fTrue;
  1701.     }
  1702.     if (wParam == IDOK || wParam == IDCANCEL) {
  1703.       EndDialog(hdlg, fTrue);
  1704.       return fTrue;
  1705.     }
  1706.     break;
  1707.   }
  1708.   return fFalse;
  1709. }
  1710.  
  1711.  
  1712. /* Processing function for the about dialog, showing copyrights and  */
  1713. /* credits, as brought up with the Help About Astrolog menu command. */
  1714.  
  1715. bool API DlgAbout(hdlg, message, wParam, lParam)
  1716. HWND hdlg;
  1717. _int message;
  1718. WORD wParam;
  1719. LONG lParam;
  1720. {
  1721.   switch (message) {
  1722.   case WM_INITDIALOG:
  1723.     return fTrue;
  1724.  
  1725.   case WM_COMMAND:
  1726.     if (wParam == IDOK || wParam == IDCANCEL) {
  1727.       EndDialog(hdlg, fTrue);
  1728.       return fTrue;
  1729.     }
  1730.     break;
  1731.   }
  1732.   return fFalse;
  1733. }
  1734. #endif /* WIN */
  1735.  
  1736. /* wdialog.c */
  1737.